<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath(); 
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+path+ "/"; 
     
%>
<!DOCTYPE html>
<html>
<head>

	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

	<title>忘记密码</title>

	<link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.min.css" />
	<style>
		tr,td{padding: 10px}
	</style>
</head>
<body>
	<div class="container">
	<br>
	<a href="login.jsp">返回登录</a>
	<center>
		<h3>找回密码</h3>
		<table>
			<tr>
				<td>手机号：</td>
				<td colspan="2"><input id="mobile" type="text" name="mobile" class="form-control"></td>
			</tr>
			<tr>
				<td>新密码：</td>
				<td  colspan="2"><input id="pwd1" type="password" name="pwd" class="form-control"></td>
			</tr>
			<tr>
				<td>确认密码：</td>
				<td  colspan="2"><input id="pwd2" type="password" name="repwd" class="form-control"></td>
			</tr>
			<tr>
				<td colspan="3" align="center">
					<button class="btn btn-info" onclick="forgetpwd()">&nbsp;&nbsp;确&nbsp;定&nbsp;&nbsp;</button>
				</td>
			</tr>		
		</table>
	</center>
	</div>
	
	
	<!-- 加载需要的js -->
	<script src="js/jquery-3.2.1.min.js"></script>
	<script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	<script src="js/md5.js" type="text/javascript"></script> 	
	<script type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">	
		/* function daojishi(){
			var time = 60;
			$('#code').attr('onclick',null);
			var setTime = setInterval(function(){
                if(time <= 0){
                    clearInterval(setTime);
                    $('#code').attr('onclick','return getauthcode(this)');
    				$('#code').text('点击刷新');		
                    return;
                }
                time--;
                $("#code").text(time+"s后刷新");
            },1000);		
		} */
		function forgetpwd(){
			var pwd1 = $("#pwd1").val();
			var pwd2 =$("#pwd2").val();
			var mobile = $('#mobile').val();
			if(pwd1 == pwd2){
				$.ajax({
  				    type:"get",
  					url:"sysUser/forgetPwd",
  				/* 	contentType:"application/json;charset=UTF-8", */
  					data:{mobile:mobile,pwd:pwd2},
  					dataType:"json", 
  					success:function(data){
  						 console.log(data)
  					 	if(data.code==200){
  					           window.location.href='<%=basePath%>'+"login.jsp";
  					 		}
  					 	}
		   });
			}else{
			alert("两次密码输入不相同");				
		}
	}
	</script>
</body>
</html>